package com.cjack.frenchexcel.dao;

import com.cjack.frenchexcel.table.MooncardTable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by root on 10/5/19
 */
public interface MooncardDao extends JpaRepository<MooncardTable, Long>, JpaSpecificationExecutor<MooncardTable> {

    public List<MooncardTable> findByDateDeDepense(String dateDeDepense);

    @Query( value = " select * from fe_mooncard where import_user_id!=?1 and date_de_depense > ?2 and date_de_depense < ?3", nativeQuery = true)
    public List<MooncardTable> findByUserIdAndDateDeDepense( Long adminUserId, String startTime, String endTime);

    @Query( value = " select sum( montant_en_devise) from fe_mooncard", nativeQuery = true)
    Double sum();

    @Query( value = " select * from fe_mooncard where check_res_account < 3 and check_res_account != -1 and source_from != 'SYNC_FROM_DEPANPERSO_TRIGGER'", nativeQuery = true)
    public List<MooncardTable> findByCheckResAccount();

    public MooncardTable findByOrderId(String orderId);
}
